/*
* Copyright 2004-2010 mb_sx@hotmail.com
* All Rights Reserved.
*/
using System;
using System.Windows.Forms;

namespace DeskNotes
{
	/// <summary>
	/// Summary description for CategoryNode.
	/// </summary>
	public class CategoryNode : DeskNotesTreeNode
	{
		     
		public CategoryNode(){
			type = DeskNotesTreeNode.CATEGORY;
		}

		public CategoryNode( string text ) : base(text)	{ 
			type = DeskNotesTreeNode.CATEGORY; 
		}

		public CategoryNode( string text, long id ) : base(text)
		{
			this.id = id;
			type = DeskNotesTreeNode.CATEGORY;
		}
		
		new internal bool IsExpanded
		{
			set
			{
				if (value)
				{
					this.Expand();
				}
				else
				{
					this.Collapse();
				}
			}
			get
			{
				return base.IsExpanded;
			}
		}

        internal override void ResetEdited()
        {
            edited = false;
            foreach (TreeNode node in this.Nodes)
            {
                ((DeskNotesTreeNode)node).ResetEdited();
            }
            this.SetImage();
        }

        internal void SetImage()
        {
            if (edited)
            {
                if (base.IsExpanded)
                {
                    ImageIndex = ArchiveForm.EXPANDED_CHANGED_IMAGE;
                    SelectedImageIndex = ImageIndex;
                }
                else
                {
                    ImageIndex = ArchiveForm.COLLAPSED_CHANGED_IMAGE;
                    SelectedImageIndex = ImageIndex;
                }
            }
            else
            {
                if (base.IsExpanded)
                {
                    ImageIndex = ArchiveForm.EXPANDED_IMAGE;
                    SelectedImageIndex = ImageIndex;
                }
                else
                {
                    ImageIndex = ArchiveForm.COLLAPSED_IMAGE;
                    SelectedImageIndex = ImageIndex;
                }
            }
        }

        
	}
}
